

<script>
	$(function(){
	$( "#dialog:ui-dialog" ).dialog( "destroy" );
		
		var name = $( "#memberName" ),
			allFields = $( [] ).add( name ),
			tips = $( ".validateTips" );

		function updateTips( t ) {
			tips
				.text( t )
				.addClass( "ui-state-highlight" );
			setTimeout(function() {
				tips.removeClass( "ui-state-highlight", 1500 );
			}, 500 );
		}

		function checkLength( o, n, min, max ) {
			if ( o.val().length > max || o.val().length < min ) {
				o.addClass( "ui-state-error" );
				updateTips( "Length of " + n + " must be between " +
					min + " and " + max + "." );
				return false;
			} else {
				return true;
			}
		}

		
		$( "#dialog-add" ).dialog({
			autoOpen: false,
			height: 550,
			width: 550,
			modal: true,
			buttons: {
				"新增": function() {
					var bValid = true;
					allFields.removeClass( "ui-state-error" );
					bValid = bValid && checkLength( name, "username", 2, 16 );
					if ( bValid ) {
						var username=$("#memberName").val();
						var remark=$("#remark").val();
						var status=$("#status").val();
						var time=$("#time").val();
						var id=$("#groupId").val();
						$.ajax({
							url:"insert.php",
							type:"POST",
							data:"id="+id+"&username="+username+"&remark="+remark+"&status="+status+"&time="+time,
							success:function(data){
								if(data)
									{location.href='index.php';}
								else{
									$( ".validateTips" ).text("新增成员失败!"); 
									}
								}
								});					
						$( this ).dialog( "close" );
					}
				},
				"取            消": function() {
					$( this ).dialog( "close" );
				}
			},
			close: function() {
				allFields.val( "" ).removeClass( "ui-state-error" );
			}
		});
		
$(".edit").click(function(){
	var id=$(this).attr("href");
	var memLeader=$(this).attr("rel");
	$( "#dialog-add" ).dialog( "open" );
	return false;
	
});
		})
</script>
<?php
session_start();
if(@!$_SESSION["name"]==$_GET["name"])
	exit("非法操作");
require_once 'include/conn.php';
$id=$_GET["id"];
$sql="select * from member where id=".$id;
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
?>
<div id="dialog-add" title="新增小组成员">
	<fieldset>
	<input type="hidden" id="groupId" value="<?php if(isset($_SESSION["groupId"])) echo $_SESSION["groupId"];?>" name="id"/>
	<label >姓名</label>
    <input type="text" id="memberName" name="username" class="text ui-widget-content ui-corner-all" autofocus="autofocus"/>
    <label for="task">任务</label>
    <textarea id="remark" name="remark"  cols="49" rows='3'>见需求系统</textarea>
    <label>状态</label>
    <select id="status" name="status">
    <option value ="正常" selected='selected'>正常</option>
    <option value ="忙碌" >忙碌</option>
    <option value="空闲" >空闲</option>
    </select>
    <label>时间(天)</label>
    <input id="time" type="text"  name="time" value="3" maxlength="2" width="20" class="text ui-widget-content ui-corner-all" />
	</fieldset>
<p class="validateTips">All form fields are required.</p>
</div>